<template>
  <div class="tab-control">
    <div
      v-for="(item, index) in titles"
      :key="index"
      class="tab-control-item"
      :class="{ active: index === currentIndex }"
      @click="currentClick(index)"
    >
      <span>{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabControl",
  data() {
    return {
      currentIndex: 0,
    };
  },
  props: {
    titles: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  methods: {
      currentClick(index){
          this.currentIndex = index;
      }
  }
};
</script>

<style scoped>
.tab-control {
  height: 44px;
  line-height: 44px;
  display: flex;
  text-align: center;
}
.tab-control-item {
  flex: 1;
}

.active span {
  padding-bottom: 5px;
  border-bottom: 1px solid var(--color-tint);
  color: var(--color-high-text);
}
/* .tab-control-item span{
    padding-bottom: 5px;
    border-bottom: 1px solid red;
} */
</style>
